package com.ysd.lis.controller.lab;

import com.ysd.common.Result;
import com.ysd.lis.annotation.LogDetail;
import com.ysd.lis.aspect.OperationType;
import com.ysd.lis.entity.lab.LabInstrSetup;
import com.ysd.lis.entity.lab.LabRptGroup;
import com.ysd.lis.request.AddRptGroupParam;
import com.ysd.lis.request.RptGroupInstrDto;
import com.ysd.lis.request.RptGroupPageParam;
import com.ysd.lis.request.lab.RptCampusParam;
import com.ysd.lis.service.lab.LabRptGroupService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * ${comments}
 *
 * @author wanghuaixing
 * @email
 * @date 2023-12-09
 */
@RestController
@RequestMapping("/api/rptGroup")
public class LabRptGroupController {
    @Autowired
    private LabRptGroupService labRptGroupService;

    @ApiOperation("获取报告单元")
    @GetMapping("/findRptGroup")
    public Result findRptGroup(@RequestParam(value = "keywords", required = false) String keywords) {
        return labRptGroupService.findRptGroup(keywords);
    }

    @ApiOperation("获取poct报告单元")
    @GetMapping("/findPoctRptGroup")
    public Result findPoctRptGroup() {
        return labRptGroupService.findPoctRptGroup();
    }

    @ApiOperation("添加报告单元")
    @PostMapping("/addRptGroup")
    @LogDetail(requestParam = "addRptGroup", operationType = OperationType.INSERT, module = "添加报告单元", content = "添加报告单元【rptGroupName】", businessName = "rptGroupName")
    public Result addRptGroup(@RequestBody AddRptGroupParam addRptGroupParam) {
        return labRptGroupService.addRptGroup(addRptGroupParam);
    }

    @ApiOperation("编辑报告单元")
    @PostMapping("/editRptGroup")
    @LogDetail(requestParam = "editRptGroup", operationType = OperationType.UPDATE, module = "编辑报告单元", content = "编辑报告单元【rptGroupName】", businessName = "rptGroupName")
    public Result editRptGroup(@RequestBody LabRptGroup rptGroup) {
        return labRptGroupService.editRptGroup(rptGroup);
    }

    @ApiOperation("根据id删除报告单元")
    @PostMapping("/deleteRptGroupById")
    @LogDetail(requestParam = "deleteRptGroupById", operationType = OperationType.DELETE, module = "删除报告单元", content = "删除报告单元【rptGroupName】", businessName = "rptGroupName")
    public Result deleteRptGroup(@RequestBody LabRptGroup rptGroup) {
        return labRptGroupService.deleteRptGroup(rptGroup);
    }

    @ApiOperation("根据ID获取报告单元单条信息")
    @GetMapping("/findRptGroupSimple")
    public Result findRptGroupSimple(@RequestParam String id) {
        return labRptGroupService.findRptGroupSimple(id);
    }

    @ApiOperation("分页查询")
    @GetMapping("/getRptGroupPageList")
    public Result getRptGroupPageList(RptGroupPageParam pageParam) {
        return labRptGroupService.getRptGroupPageList(pageParam);
    }

    @ApiOperation("分页查询")
    @GetMapping("/findRptGroupList")
    public Result findRptGroupList(RptGroupPageParam pageParam) {
        return labRptGroupService.findRptGroupList(pageParam);
    }

    @ApiOperation("报告单元查询")
    @PostMapping("/getRptGroupList")
    public Result getRptGroupList(@RequestBody RptGroupPageParam pageParam) {
        return labRptGroupService.getRptGroupList(pageParam);
    }

    @ApiOperation("根据ID获取当前报告单元下的仪器")
    @GetMapping("/findInstrByRptGroupId")
    public Result findInstrByRptGroupId(@RequestParam String id) {
        return labRptGroupService.findInstrByRptGroupId(id);
    }

    @ApiOperation("获取当前报告单没对照的仪器列表")
    @GetMapping("/findInstrsByRptGroupId")
    public Result findInstrsByRptGroupId(RptGroupPageParam param) {
        return labRptGroupService.findInstrsByRptGroupId(param);
    }

    @ApiOperation("批量新增仪器")
    @PostMapping("/batchAddInstrList")
    @LogDetail(requestParam = "batchAddInstrList", operationType = OperationType.INSERT, module = "添加仪器对照", content = "添加仪器【instrName】", businessName = "instrName")
    public Result batchAddInstrList(@RequestBody RptGroupInstrDto dto) {
        return labRptGroupService.batchAddInstrList(dto);
    }

    @ApiOperation("删除对照的仪器")
    @PostMapping("/deleteInstr")
    @LogDetail(requestParam = "deleteInstr", operationType = OperationType.UPDATE, module = "删除对照的仪器", content = "删除对照的仪器【instrName】", businessName = "instrName")
    public Result deleteInstr(@RequestBody LabInstrSetup labInstrSetup) {
        return labRptGroupService.deleteInstr(labInstrSetup);
    }

    @ApiOperation("同步报告单元")
    @GetMapping("/syncRptGroups")
    public Result syncRptGroups() {
        return labRptGroupService.syncRptGroups();
    }

    @ApiOperation("获取报告单元")
    @GetMapping("/findRptGroupByCampusArea")
    public Result findRptGroupByCampusArea(RptCampusParam param) {
        return labRptGroupService.findRptGroupByCampusArea(param);
    }

    @ApiOperation("分页查询")
    @GetMapping("/getRptGroupPoctList")
    public Result getRptGroupPoctList(RptGroupPageParam pageParam) {
        return labRptGroupService.getRptGroupPoctList(pageParam);
    }
}
